class Courier < ActiveRecord::Base

  belongs_to :user

  has_many :checklist_instances  
  has_many :checklist_recurrence_rules

  has_many :route_instances
  has_many :route_recurrence_rules
  
  has_many :carrying, :class_name => 'Items', :foreign_key => 'carried_by'  
  
  validate :has_user  
  
  # Wrappers for form helpers
  def account_name
    user.account_name
  end
  def real_name
    user.real_name
  end
  
private
  
  # password can't be blank
  def has_user
    errors.add(:user, "Missing/invalid user") unless User.find(user_id)
  end
end
